home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / amac44a.zip / COM004.QM < prev    next >
Text File  |  1992-06-22  |  44KB  |  905 lines

  1. *                                com004.qm
  2. *                     Macros to Comment and Un-Comment
  3. *                             By Tom Hogshead
  4. *                       [ See COMTxx.QM For Use ]
  5. *                                 6/22/92
  6. *
  7. *  New  Old
  8. *   @1   @1  Shifts Lines, Stars in Col 1  (QEdit v2.10 only)
  9. *   @2   @5  Shifts Lines, Stars in Col 1  (QEdit v2.15 only)
  10. *
  11. *   @3   @2  Preserve Juxtaposition, Stars in Col 1
  12. *   @4   @3  Preserve Juxtaposition, Stars Two Spaces Left of First Character
  13. *
  14. *   @5   @6  Preserve Indention, Stars at First Character of Each Line
  15. *   @6   @4  Preserve Indention, Stars at First Character of Block
  16. *
  17. *       Description
  18. *       Commenting/Un-Commenting Functions, Examples
  19. *       Summary of Macro Key Functions
  20. *       Keys Summary Commenting
  21. *       Preference/Key Assignment
  22. *       Macros
  23. *
  24. *      {e:\up\COMT*}   Return To COMTxx.QM
  25. *
  26. *-- eoi
  27.  
  28.  
  29. * 
  30. * (Description)
  31. * --------------
  32. * The following set  of QEdit macros provide  a means to easily comment
  33. * and un-comment lines and blocks.  Each line is commented by inserting
  34. * an asterisk  as the  first character in  a line,  and un-commented by
  35. * removing  the asterisk.   Each macro  will both  comment un-commented
  36. * lines and  un-comment commented  lines.  A  line block  may be marked
  37. * before invoking, either  open or closed,  and all lines  in the block
  38. * will be processed  without pausing.  If a  block is not marked before
  39. * invoking, the  macro opens a  line block  and pauses for  the user to
  40. * cursor to the end of the block and hit <enter>.
  41.  
  42. * What the  macros do  and what  commented  and un-commented lines look
  43. * like can be seen below in section Commenting Functions.  The centered
  44. * comment lines,  with the commenting '*' character in col 5, were made
  45. * with @2 in Amac44.zip com001.qm.
  46.  
  47. * 
  48. * A Few Notes  
  49. * ------------  
  50. *   a)  A line, column or character block may be marked before
  51. *       invoking, either open or closed, and block will be processed
  52. *       without pausing.
  53. *   b)  Blank lines are not commented (except @5), but macros are
  54. *       easily modifiable to do so, as shown in the macro.
  55. *   c)  Macros, except @5, will not work correctly if in any
  56. *       'out-dention' occurs after line 1 in the block.
  57. *   d)  Macros may be modified to comment blank lines by replacing
  58. *       #32 with #42 (asterisk) and removing the findreplace lines
  59. *       (@1/2/3/4).
  60. *   e)  Commenting star must be separated from firstnonwhite character
  61. *       at least one space when un-commenting.
  62. *   f)  Ascii #173 (eob marker) must not exist in file for @3 or @4.
  63. *   g)  Commented lines w/text in col's 1-2 before commenting must
  64. *       not have user inserted invisible Ascii #255 character(s) in
  65. *       line, otherwise lines will not be returned to their original
  66. *       position when un-commenting with @3 or @4.
  67. *   h)  Lines commented with @3 and @4 having text in col's 1-2
  68. *       before commenting must not have appended invisible Ascii #255
  69. *       character(s) at eol removed, otherwise lines will not be
  70. *       returned to their original position when un-commenting with
  71. *       @3 or @4.
  72.  
  73.  
  74. * (Commenting)/Un-Commenting Functions, Examples
  75. * -----------------------------------------------
  76. * The functions of these macros can be seen in the following examples:
  77.  
  78. * 
  79. * A)    With boxes removed and 'As Is' column in col 4, commenting
  80. *       the first three lines:
  81.  
  82. *                            <-------    Preserve      ------->
  83. *                   Shift    <-- Juxtaposition  -->  Indention
  84. *    ┌─ As Is ┐  ┌ @1/@2  ┐  ┌── @3 ──┐  ┌── @4───┐  ┌ @5/@6  ┐
  85. *        aaa  │  *     aaa│  *   aaa  │  ∙ * aaa  │  ∙   * aaa│
  86. *        aaa  │  *     aaa│  *   aaa  │  ∙ * aaa  │  ∙   * aaa│
  87. *        aaa  │  *     aaa│  *   aaa  │  ∙ * aaa  │  ∙   * aaa│
  88. *        aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │
  89. *        aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │
  90. *        aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │  ∙   aaa  │
  91. *    123456789┘  123456789┘  123456789┘  123456789┘  123456789┘
  92. *                <-  Star in Col 1   ->
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103. * 
  104. * B)    Commenting a line of text in col's 1, 2, 3, 4, 5 gives:
  105.  
  106. *  ┌── c1 ──┐  ┌── c2───┐  ┌── c3 ──┐  ┌── c4 ──┐  ┌── c5 ──┐
  107. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │       As Is
  108. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │        |
  109. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │        |
  110. *  * aaa    ∙  *  aaa   ∙  *   aaa  ∙  *    aaa ∙  *     aaa│ @1/@2 Comt
  111. *  * aaa    ∙  * aaa    ∙  * aaa    ∙  *  aaa   ∙  *   aaa  │ @3     |
  112. *  * aaa    ∙  * aaa    ∙  * aaa    ∙  ∙* aaa   ∙  ∙ * aaa  │ @4     |
  113. *  * aaa    ∙  ∙* aaa   ∙  ∙ * aaa  ∙  ∙  * aaa ∙  ∙   * aaa│ @5/@6  |
  114. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │ @1/@2 Un-Comt
  115. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │ @3     |
  116. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │ @4     |
  117. *  aaa      ∙  ∙aaa     ∙  ∙ aaa    ∙  ∙  aaa   ∙  ∙   aaa  │ @5/@6  |
  118. * [123456789┘  123456789┘  123456789┘  123456789┘  123456789┘
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. * 
  129. * C)    Lines 2 and 3 of each set, positioned in col 1 w/o boxes,
  130. *       is commented.  Then line 3 is un-commented:
  131.  
  132. *                               <-------   Preserve   -------->
  133. *                     Shift     <- Juxtaposition  ->  Indention
  134. *        ┌ As Is ┐   ┌ @1/@2 ┐  ┌─ @3 ──┐  ┌─ @4 ──┐  ┌ @5/@6 ┐
  135. *        aaa     │   aaa     ∙  aaa     ∙  aaa     ∙  aaa     │
  136. *        aaa     │   * aaa   ∙  * aaa   ∙  * aaa   ∙  * aaa   │
  137. *        aaa     │   aaa     ∙  aaa     ∙  aaa     ∙  aaa     │
  138. *                │   ∙       ∙  ∙       ∙  ∙       ∙  ∙       │
  139. *         aaa    │   ∙aaa    ∙  ∙aaa    ∙  ∙aaa    ∙  ∙aaa    │
  140. *         aaa    │   *  aaa  ∙  * aaa   ∙  * aaa   ∙  ∙* aaa  │
  141. *         aaa    │   ∙aaa    ∙  ∙aaa    ∙  ∙aaa    ∙  ∙aaa    │
  142. *                │   ∙       ∙  ∙       ∙  ∙       ∙  ∙       │
  143. *          aaa   │   ∙ aaa   ∙  ∙ aaa   ∙  ∙ aaa   ∙  ∙ aaa   │
  144. *          aaa   │   *   aaa ∙  * aaa   ∙  * aaa   ∙  ∙ * aaa │
  145. *          aaa   │   ∙ aaa   ∙  ∙ aaa   ∙  ∙ aaa   ∙  ∙ aaa   │
  146. *                │   ∙       ∙  ∙       ∙  ∙       ∙  ∙       │
  147. *           aaa  │   ∙  aaa  ∙  ∙  aaa  ∙  ∙  aaa  ∙  ∙  aaa  │
  148. *           aaa  │   *    aaa∙  *  aaa  ∙  ∙* aaa  ∙  ∙  * aaa│
  149. *           aaa  │   ∙  aaa  ∙  ∙  aaa  ∙  ∙  aaa  ∙  ∙  aaa  │
  150. *        12345678┘   12345678┘  12345678┘  12345678┘  12345678┘
  151. *                    <- Star in Col 1  ->
  152.  
  153.  
  154.  
  155. * 
  156. * D)     Marking lines 3-10 of the following @5 and @6 gives:
  157.  
  158. *     ┌── As Is  ──┐  ┌──── @5 ────┐  ┌──── @6 ────┐
  159. *         aaa      │  ∙   aaa      │    * aaa      │
  160. *         aaa      │  ∙   aaa      │    * aaa      │
  161. *         aaa      │  ∙   * aaa    │    * aaa      │
  162. *         aaa      │  ∙   * aaa    │    * aaa      │
  163. *                  │  ∙   *        │               │
  164. *             aaa  │  ∙       * aaa│    *     aaa  │
  165. *             aaa  │  ∙       * aaa│    *     aaa  │
  166. *                  │  ∙       *    │               │
  167. *     aaa          │  * aaa        │  aa           │
  168. *     aaa          │  * aaa        │  aa           │
  169. *     1234567890123┘  1234567890123┘  1234567890123┘
  170. *                                       ^
  171. *                                       Error, no out-dention except @5  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180. * To test, un-comment with @3 or @4
  181. * ----------------------------------
  182. *         aaa
  183. *         aaa
  184. *         aaa
  185. *         aaa
  186.  
  187. *             aaa
  188. *             aaa
  189.  
  190. *     aaa
  191. *     aaa
  192. * ----1234567890123
  193.  
  194. * 
  195. *  My (preference) #1              #2             #3             #4
  196. *  Key            ^Dn             @Dn            @Up            ^Lft
  197. *              ┌── @3 ──┐      ┌── @4───┐     ┌── @2 ──┐     ┌── @6 ──┐
  198. *              *   aaa  │      ∙ * aaa  │     *     aaa│     ∙   * aaa│
  199. *              *   aaa  │      ∙ * aaa  │     *     aaa│     ∙   * aaa│
  200. *              *   aaa  │      ∙ * aaa  │     *     aaa│     ∙   * aaa│
  201. *                  aaa  │      ∙   aaa  │     ∙   aaa  │     ∙   aaa  │
  202. *                  aaa  │      ∙   aaa  │     ∙   aaa  │     ∙   aaa  │
  203. *                  aaa  │      ∙   aaa  │     ∙   aaa  │     ∙   aaa  │
  204. *              └────────┘      └────────┘     └────────┘     └────────┘
  205.  
  206.  
  207. * 
  208. *    ┌──────────────────────────────────────┐
  209. *    │   (Summary) of Macro Key Functions   │
  210. *    └───────────────── ( ) ────────────────┘             Alt Key
  211. *   COMMENTING               Inserts star space col 1··1··2··3··4········
  212. *                              Preserve juxtaposition········3··4········
  213. *                                  Preserve indention··············5··6··
  214. *                                 Comment Blank Lines              5
  215. *       Inserts star space at firstnonwhite each line··············5·· ··
  216. *        Inserts star space at firstnonwhite in block·················6··
  217. *         Inserts star 2 char's left of firstnonwhite···········4········
  218. *           Shifts only col 1-2 text lines to col 3-4········3··4········
  219. *         Shifts all lines in block two columns right··1··2········5··6··
  220. *
  221. *   UN-COMMENTING              Preserve juxtaposition········3··4·· ·····
  222. *                                  Preserve indention··············5··6··
  223. *                 Will un-comment stars only in col 1··1·················
  224. *               Returns all text to original position··1··2··3··4··5··6··
  225. *          Will un-comment stars as in any first char·····2··3··4··5··6··
  226. *           Returns col 1-2 text to original position········3··4·· ·····
  227. *
  228. *                                Requires QEdit v2.10··1·················
  229. *                                Requires QEdit v2.15·····2··3··4··5··6··
  230. *                     Fits on one line of Qconfig.dat··1··2········5··6··
  231.  
  232. * 
  233. *               ┌────────────────────────────────────┐
  234. *               │     (Keys) Summary Commenting      │
  235. *               └────────────────────────────────────┘
  236. *                       Shifts all lines in block 2 columns right ─┐
  237. *                    Shifts only col 1-2 text lines to col 3-4 ─┐  │
  238. *               Inserts star 2 char's left of firstnonwhite ─┐  │  │
  239. *                                   Comment Blank Lines  ─┐  │  │  │
  240. *                  Inserts star space at firstnonwhite ┐  │  │  │  │
  241. *                               Preserve indention ─┐  │  │  │  │  │
  242. *                        Preserve juxtaposition ─┐  │  │  │  │  │  │
  243. *                   Inserts star space col 1 ─┐  │  │  │  │  │  │  │ Bytes
  244. *                                                                    -----
  245. *                                      @1·····1····················1·· 71
  246. *                                      @2·····2····················2·· 72
  247. *                                      @3·····3··3···········3··3·····175
  248. *                                      @4·····4··4··············4·····177
  249. *                                      @5···········5··5··5········5·· 70
  250. *                                      @6···········6··6···········6·· 72
  251.  
  252.  
  253.  
  254. * (Macros)
  255. *
  256. *                            M A C R O S
  257. * -------------------------------------------------------------------
  258. * @(1)  Comment or Un-Comment Line or Block,
  259. *       Insert 'Star'Space in Col 1,
  260. *       Shifts All Lines Right Two Spaces Commenting,
  261. *       Shift Lines to Original Position Un-Commenting
  262. *       Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
  263. *       (Tom Hogshead and John Goodman authors)
  264. * -------------------------------------------------------------------
  265. * See Examples A, B and C above.
  266.  
  267. @1  MacroBegin
  268.         CursorRight                 * Needed for single line blocks
  269.         GotoBlockBeg JTrue A        * Test if block closed
  270.         MarkLine                    * Set line block marker
  271.         GotoBlockBeg JTrue OK       * Test again if block closed
  272.         Pause                       * Nothing marked, let user mark it
  273.         Jump B                      * Jump to finish block
  274.    A:                               * Here if both ends originally marked
  275.         GotoBlockEnd UnmarkBlock    * Remove block completely
  276.         MarkLine PrevPosition
  277.    B:
  278.         MarkLine                    * Convert start block to line block
  279.         GotoBlockBeg                * Make sure we're at the beginning
  280.    OK:                              * Now have completed line block
  281.       * setscreenoff                * Un-comment for QEdit v2.15
  282.     * --------------- Check If Block Already Commented --------------*
  283.         BegLine CursorRight         * Position cursor for find
  284.         Find "*" Return             * Test if line is already commented
  285.         "LB" Return                 *(assumes all block commented or not)
  286.         Jfalse COMMENT              * If no star in col 1, must comment
  287.     * ---------------------- Un-Comment Block -----------------------*
  288.     UNCOMMENT:                      *ELSE
  289.         ShiftLeft ShiftLeft         * Col 1 has star, uncomment block
  290.         Jump END                    * End macro
  291.     * ------------------------ Comment Block ------------------------*
  292.     COMMENT:
  293.         ShiftRight ShiftRight       * Shift all lines right twice
  294.         BegLine                     * Move cursor to col 1
  295.         GotoBlockEnd                * Move to 1st char of last line
  296.         MarkColumn                  * Mark 1st char, column block
  297.         PrevPosition                * Return to block begin col 2
  298.         begline                     * Needed for single-line case
  299.         markcolumn                  * Close column block to go to at end
  300.         FillBlock                   * Fill block
  301.             #32  Return             * with space #32 (Change #32 to any
  302.                                     * Ascii char to comment blank lines)
  303.         FindReplace                 * Replace
  304.             #32  Return             * space
  305.             "*"  Return             * with "*"
  306.             "LN" Return             * Local, No Prompt Replace
  307.     END:
  308.         GoToBlockEnd UnmarkBlock    * Unmark block
  309.         begline CursorDown          * Go to line after block col 1
  310. *
  311. * 46 bytes Sun  03-31-1991  01:51:24 (TH/JG @8)
  312. * 58 bytes Tue  04-30-1991  19:06:16 (TH/JG @3 not comment blank lines)
  313. * 66 bytes Mon  05-27-1991  18:55:32 (TH sent to JG as @7)
  314. * 65 bytes Tue  07-09-1991  14:49:01 (TH ^cursordown, line blocks only)
  315. * 78 bytes Tue  07-09-1991  15:09:58 (TH ^cursordown, col/char blocks OK,)
  316. * 74 bytes Tue  07-09-1991  23:15:04 (TH ^cursordown, shortened/sent to JG)
  317. * 74 bytes Thu  07-11-1991  23:09:20 (TH ^CursorDown, moved begline up)
  318. * 71 bytes Tue  07-23-1991  20:49:09 (JG @1, Replaced all above OK: label)
  319. * 71 bytes Tue  07-23-1991  20:49:09 (JG/TH ^cursordown, shortened)
  320. *                   (In Amac43.zip)
  321. * 71 bytes Tue  06-09-1992  16:29:39 (TH @1, to ALL #3/863, 6/13/92)
  322.  
  323.  
  324. * QConfig Version To Fit
  325. * -----------------------
  326. * Changing "Label" to "L", the following QMAC compiled version will fit
  327. * on one line of QConfig.dat:
  328.  
  329. * @1 macrobegin cursorright gotoblockbeg jtrue L0 markline gotoblockbeg
  330. *    jtrue L1 pause jump L2 L0: gotoblockend unmarkblock markline
  331. *    prevposition L2: markline gotoblockbeg L1: begline cursorright
  332. *    find "*" return "LB" return jfalse L3 shiftleft shiftleft jump L4
  333. *    L3: shiftright shiftright begline gotoblockend markcolumn
  334. *    prevposition begline markcolumn fillblock #32 return findreplace
  335. *    #32 return "*" return "LN" return L4: gotoblockend unmarkblock
  336. *    begline cursordown
  337. * 71 bytes Tue  07-23-1991  20:49:09 (JG/TH @1)
  338.  
  339. * Single line (464 chars)
  340. * ------------------------
  341. * @1 macrobegin cursorright gotoblockbeg jtrue L0 markline gotoblockbeg jtrue L1 pause jump L2 L0: gotoblockend unmarkblock markline prevposition L2: markline gotoblockbeg L1: begline cursorright find "*" return "lb" return jfalse L3 shiftleft shiftleft jump L4 L3: shiftright shiftright begline gotoblockend markcolumn prevposition begline markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock begline cursordown
  342. *
  343. * 71 bytes Tue  07-23-1991  20:49:09 (JG/TH @1)
  344.  
  345.  
  346. * 
  347. * -------------------------------------------------------------------
  348. * @(2)  Comment or Un-Comment Line or Block, (More versatile Version of @1)
  349. *       Insert 'Star'Space in Col 1,
  350. *       Shifts All Lines Right Two Spaces Commenting,
  351. *       Shift All Lines to Original Position Un-Commenting,
  352. *       Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
  353. *    >> Will Un-Comment All Stars as First Character,
  354. *    >> Requires QEdit v2.15
  355. * -------------------------------------------------------------------
  356. * See Examples A, B and C above.
  357.  
  358. @2  macrobegin
  359.     setsoundoff
  360.         gotoblockend jtrue OK markline
  361.         gotoblockend jtrue OK
  362.         pause                       * Select block if not closed
  363.         markline                    * And close it
  364.     OK:
  365.         setscreenoff
  366.         addline                     * Add line for single line blocks
  367.         markline                    * Extend block to include blank line
  368.         gotoblockbeg
  369.     * ------------------- Test If Block Commented -------------------*
  370.         firstnonwhite cursorright   * Pos 1 spc rt of first char in line
  371.         find "*" return             * Test if line is commented
  372.         "LB" return                 *(assumes all block commented or not)
  373.         jfalse COMMENT              * If no star as first char, comment
  374.     * ---------------------- Un-Comment Block -----------------------*
  375.     UNCOMMENT:                      *ELSE we must un-comment
  376.         firstnonwhite
  377.         delch delch                 * Delete star space
  378.         cursordown                  * Move down 1 line to test if at eob
  379.         iscursorinblock             * Test if past eob
  380.         jtrue UNCOMMENT             * If so, cont until out of block
  381.         jump END                    *ELSE end macro
  382.     * ------------------------ Comment Block ------------------------*
  383.     COMMENT:
  384.         shiftright shiftright       * Shift all lines right twice
  385.         begline                     * Move cursor to col 1
  386.         gotoblockend                * Move to 1st char of last line
  387.         markcolumn                  * Mark 1st char, column block
  388.         prevposition                * Return to block begin col 2
  389.         markcolumn                  * Close column block to go to at end
  390.         fillblock                   * Fill single column block
  391.             #32  Return             * with space #32 (Change #32 to any
  392.                                     * Ascii char to comment blank lines)
  393.         findreplace                 * Replace
  394.             #32  return             * space
  395.             "*"  return             * with "*"
  396.             "LN" return             * Local, No Prompt Replace
  397.     END:
  398.         gotoblockend unmarkblock
  399.         delline begline             * Delete extra blank line
  400. *
  401. * 72 bytes Sun  06-21-1992  17:57:50 (TH @2)
  402.  
  403. * QConfig Version To Fit
  404. * -----------------------
  405. * Changing "Label" to "L", the following QMAC compiled version will fit
  406. * on one line of QConfig.dat:
  407.  
  408. * @2 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend
  409. *    jtrue L1 pause markline L1: setscreenoff addline markline
  410. *    gotoblockbeg firstnonwhite cursorright find "*" return "lb" return
  411. *    jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock
  412. *    jtrue L3 jump L4 L2: shiftright shiftright begline gotoblockend
  413. *    markcolumn begline markcolumn fillblock #32 return findreplace #32
  414. *    return "*" return "ln" return L4: gotoblockend unmarkblock delline
  415. *    begline
  416. * 72 bytes Sun  06-21-1992  17:57:50
  417.  
  418. * Single line (472 chars)
  419. * ------------------------
  420. * @2 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend jtrue L1 pause markline L1: setscreenoff addline markline gotoblockbeg firstnonwhite cursorright find "*" return "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock jtrue L3 jump L4 L2: shiftright shiftright begline gotoblockend markcolumn prevposition markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock delline begline
  421. *
  422. * 72 bytes Sun  06-21-1992  17:57:50
  423.  
  424. * 
  425. * -------------------------------------------------------------------
  426. * @(3)  Comment or Un-Comment Line or Block,
  427. *       Preserve Text Juxtaposition (Except text in col's 1-2),
  428. *    >> Insert 'Star Space' in Col 1,
  429. *       Shifts Lines w/Text in Col's 1-2 to Col 3-4 When Commenting,
  430. *       Shifts Previous Col 1-2 Lines Back Where They Were Un-Commenting,
  431. *       Does Not Shift Other Lines when Un-Commenting,
  432. *       Will Un-Comment All Stars as First Character,
  433. *       This Macro Will Not Fit One Line of Qconfig.dat,
  434. *       Requires QEdit v2.15
  435. * -------------------------------------------------------------------
  436. * Since this macro will not fit on one line of qconfig.dat, a NewKey
  437. * macro can be used to call and execute this macro so it is available
  438. * at all times without having to manually load.
  439.  
  440. * See Examples A, B and C above.
  441.  
  442. @3  MacroBegin
  443.     savesettings setinsmode setsoundoff                                  *:
  444.     setwordwrapmode togglewordwrap
  445.         gotoblockend jtrue OK markline
  446.         gotoblockend jtrue OK
  447.         pause                       * Select block if not closed
  448.         markline                    * And close it
  449.     OK:
  450.         setscreenoff
  451.         addline begline cursorright * Add line for eob marker
  452.         #173                        * Insert eob marker empty line *col 2
  453.         markline                    * Extend block to include blank line
  454.     * ------------------- Test If Block Commented -------------------*
  455.         gotoblockbeg
  456.         firstnonwhite cursorright   * Pos 1 spc rt of first char line 1
  457.         find "*"  return            * Test if line 1 is commented
  458.              "LB" return            *(assumes all block commented or not)*:
  459.         jfalse COMMENT              * If no star as first char, comment
  460.     * ========================== Un-Comment =========================*
  461.     UNCOMMENT:                      *ELSE we must un-comment
  462.         firstnonwhite
  463.         delch #32                   * Delete star/shift line rt 1 spc    *:
  464.         cursordown cursordown       * Move down 2 lines to test if at eob*:
  465.         iscursorinblock             * Test if past eob                   *:
  466.         jfalse SHIFTBACK            * If not, shift back to col 1-2      *:
  467.             cursorup                * Still in block, move up 1 line     *:
  468.             jump UNCOMMENT          * Continue 'til block un-commented   *:
  469.                      *  Shift Lines w/Text in Col 3  *
  470.     * ----------------- to Col 1/2 If There To Start ----------------*
  471.         SHIFTBACK:
  472.             gotoblockbeg begline    * Pos for col 1-2 shiftback          *:
  473.             unmarkblock markline
  474.             find                    * Test/move to #255 in line
  475.                 #255 return
  476.                 'L' return
  477.             jfalse WAS_COL3         * If no #255's, line was not shifted
  478.                                     * from col 1 or 2
  479.                 unmarkblock
  480.                 markcolumn          * Mark first #255 in line
  481.                 endline cursorleft
  482.                 cut                 * Cut all #255's at eol to scrap
  483.                 begline pasteover   * Paste at bol
  484.                 deleteblock         * Returns line to original
  485.                                     * un-commented juxtaposition
  486.             WAS_COL3:
  487.             cursordown endline      * Pos eol to test if past eob marker *:
  488.             find
  489.                 #173 return
  490.                 delline return
  491.             jfalse END              * End macro if past eob marker
  492.                 prevposition        * If not, return to line we were in
  493.         jump SHIFTBACK              * Continue to test/shiftback 'til done
  494.     * =========================== Comment ===========================*
  495.     COMMENT:
  496.         findreplace                 * Remove
  497.             #255 return             * all stray #255's
  498.             delline return
  499.             'GLN' return            * from block before commenting
  500.     * --------- Shift Lines With Text in Col 1-2 to Col 3-4 ---------*
  501.         firstnonwhite               * Re-position on firstnonwhite
  502.         PUSH_COL3:
  503.             isemptyline                                                  *:21
  504.             jtrue COL2              * Bypass empty lines                 *:21
  505.             isbegline               * Test if first char in col 1
  506.             jfalse COL1
  507.                 #32 #32             * If so, shift col 1 line 2 spcs rt
  508.                 endline
  509.                 #255 #255           * Insert 2 eol markers, was col 1
  510.                 jump COL2
  511.             COL1:
  512.                 cursorleft
  513.                 isbegline           * Test if first char in col 2
  514.                 jfalse COL2
  515.                     #32             * If so, shift col 2 line 1 spc rt
  516.                     endline
  517.                     #255            * Insert 1 eol marker, was col 2
  518.                 COL2:
  519.                     cursordown      * Move to next line
  520.                     cursordown
  521.                     iscursorinblock * Test if we're past block
  522.                     jfalse SHIFTED  * If we are, it's time to insert stars
  523.                       cursorup      * Move back to next line to comment
  524.                       firstnonwhite * Return to first char of next line
  525.         jump PUSH_COL3              * Push 'till all out of col's 1-2
  526.    SHIFTED:
  527.     * ----------------- Insert Stars For Commenting -----------------*
  528.         gotoblockbeg
  529. *-- @3
  530.         begline                                                          *:
  531. *-- @4
  532.       * firstnonwhite
  533.       * cursorleft cursorleft       * Pos 2 spcs left of firstnonwhite
  534. *--
  535.         gotoblockend markcolumn
  536.         prevposition markcolumn     * Finish blk spsc lft of firstnonwhite
  537.         fillblock                   * Fill single column block
  538.             #32  Return             * with space #32 (Change #32 to any
  539.                                     * Ascii char to comment blank lines)
  540.         findreplace                 * Replace
  541.             #32  return             * space
  542.             "*"  return             * with "*"
  543.             "LN" return             * Local, No Prompt Replace
  544.     END:
  545.         gotoblockend unmarkblock
  546.         delline begline             * Delete extra blank line
  547.         restoresettings                                                  *:
  548. *
  549. *  69 bytes Tue  06-09-1992  22:01:02 (TH @3, to ALL #3/864, 6/13/92)
  550. * 116 bytes Fri  06-19-1992  13:51:31 (TH @3, improved col 1-2 routine)
  551. * 165 bytes Sat  06-20-1992  01:19:59 (TH @3, un-comment stars any col)
  552. * 166 bytes Sat  06-20-1992  13:33:38 (TH @3, corrected un-comment)
  553. * 166 bytes Sat  06-20-1992  16:48:07 (TH @3, changed cursorright to endline)
  554. * 167 bytes Sat  06-20-1992  17:05:36 (TH @3, added begline)
  555. * 169 bytes Sat  06-20-1992  17:23:32 (TH @3, changed 'LN' to 'GLN')
  556. * 171 bytes Sat  06-20-1992  17:29:00 (TH @3, added restoresettings)
  557. * 175 bytes Sun  06-21-1992  16:37:56 (TH @3, bypass empty lines)
  558.  
  559. * 
  560. * -------------------------------------------------------------------
  561. * @(4)  Comment or Un-Comment Line or Block,
  562. *       Preserve Text Juxtaposition (Except text in col's 1-2),
  563. *    >> Insert 'Star' Left of FirstNonWhite Two Spaces Commenting,
  564. *       Shifts Lines w/Text in Col's 1-2 to Col 3-4 When Commenting,
  565. *       Shifts Previous Col 1-2 Lines Back Where They Were Un-Commenting,
  566. *       Does Not Shift Other Lines when Un-Commenting,
  567. *       Will Un-Comment All Stars as First Character,
  568. *       This Macro Will Not Fit One Line of Qconfig.dat,
  569. *       Requires QEdit v2.15
  570. * -------------------------------------------------------------------
  571. * Since this macro will not fit on one line of qconfig.dat, a NewKey
  572. * macro can be used to call and execute this macro so it is available
  573. * at all times without having to manually load.
  574.  
  575. * See Examples A, B and C above.
  576.  
  577. @4  macrobegin
  578.     savesettings setinsmode setsoundoff                                  *:
  579.     setwordwrapmode togglewordwrap
  580.         gotoblockend jtrue OK markline
  581.         gotoblockend jtrue OK
  582.         pause                       * Select block if not closed
  583.         markline                    * And close it
  584.     OK:
  585.         setscreenoff
  586.         addline begline cursorright * Add line for eob marker
  587.         #173                        * Insert eob marker empty line *col 2
  588.         markline                    * Extend block to include blank line
  589.     * ------------------- Test If Block Commented -------------------*
  590.         gotoblockbeg
  591.         firstnonwhite cursorright   * Pos 1 spc rt of first char line 1
  592.         find "*"  return            * Test if line 1 is commented
  593.              "LB" return            *(assumes all block commented or not)*:
  594.         jfalse COMMENT              * If no star as first char, comment
  595.     * ========================== Un-Comment =========================*
  596.     UNCOMMENT:                      *ELSE we must un-comment
  597.         firstnonwhite
  598.         delch #32                   * Delete star/shift line rt 1 spc    *:
  599.         cursordown cursordown       * Move down 2 lines to test if at eob*:
  600.         iscursorinblock             * Test if past eob                   *:
  601.         jfalse SHIFTBACK            * If not, shift back to col 1-2      *:
  602.             cursorup                * Still in block, move up 1 line     *:
  603.             jump UNCOMMENT          * Continue 'til block un-commented   *:
  604.                      *  Shift Lines w/Text in Col 3  *
  605.     * ----------------- to Col 1/2 If There To Start ----------------*
  606.         SHIFTBACK:
  607.             gotoblockbeg begline    * Pos for col 1-2 shiftback          *:
  608.             unmarkblock markline
  609.             find                    * Test/move to #255 in line
  610.                 #255 return
  611.                 'L' return
  612.             jfalse WAS_COL3         * If no #255's, line was not shifted
  613.                                     * from col 1 or 2
  614.                 unmarkblock
  615.                 markcolumn          * Mark first #255 in line
  616.                 endline cursorleft
  617.                 cut                 * Cut all #255's at eol to scrap
  618.                 begline pasteover   * Paste at bol
  619.                 deleteblock         * Returns line to original
  620.                                     * un-commented juxtaposition
  621.             WAS_COL3:
  622.             cursordown endline      * Pos eol to test if past eob marker *:
  623.             find
  624.                 #173 return
  625.                 delline return
  626.             jfalse END              * End macro if past eob marker
  627.                 prevposition        * If not, return to line we were in
  628.         jump SHIFTBACK              * Continue to test/shiftback 'til done
  629.     * =========================== Comment ===========================*
  630.     COMMENT:
  631.         findreplace                 * Remove
  632.             #255 return             * all stray #255's
  633.             delline return
  634.             'GLN' return            * from block before commenting
  635.     * --------- Shift Lines With Text in Col 1-2 to Col 3-4 ---------*
  636.         firstnonwhite               * Re-position on firstnonwhite
  637.         PUSH_COL3:
  638.             isemptyline                                                  *:
  639.             jtrue COL2              * Bypass empty lines                 *:
  640.             isbegline               * Test if first char in col 1
  641.             jfalse COL1
  642.                 #32 #32             * If so, shift col 1 line 2 spcs rt
  643.                 endline
  644.                 #255 #255           * Insert 2 eol markers, was col 1
  645.                 jump COL2
  646.             COL1:
  647.                 cursorleft
  648.                 isbegline           * Test if first char in col 2
  649.                 jfalse COL2
  650.                     #32             * If so, shift col 2 line 1 spc rt
  651.                     endline
  652.                     #255            * Insert 1 eol marker, was col 2
  653.                 COL2:
  654.                     cursordown      * Move to next line
  655.                     cursordown
  656.                     iscursorinblock * Test if we're past block
  657.                     jfalse SHIFTED  * If we are, it's time to insert stars
  658.                       cursorup      * Move back to next line to comment
  659.                       firstnonwhite * Return to first char of next line
  660.         jump PUSH_COL3              * Push 'till all out of col's 1-2
  661.    SHIFTED:
  662.     * ----------------- Insert Stars For Commenting -----------------*
  663.         gotoblockbeg
  664. *-- @3
  665.       * begline
  666. *-- @4
  667.         firstnonwhite                                                    *:
  668.         cursorleft cursorleft       * Pos 2 spcs left of firstnonwhite   *:
  669. *--
  670.         gotoblockend markcolumn
  671.         prevposition markcolumn     * Finish blk spsc lft of firstnonwhite
  672.         fillblock                   * Fill single column block
  673.             #32  Return             * with space #32 (Change #32 to any
  674.                                     * Ascii char to comment blank lines)
  675.         findreplace                 * Replace
  676.             #32  return             * space
  677.             "*"  return             * with "*"
  678.             "LN" return             * Local, No Prompt Replace
  679.     END:
  680.         gotoblockend unmarkblock
  681.         delline begline             * Delete extra blank line
  682.         restoresettings                                                  *:
  683. *
  684. * 116 bytes Sat  06-13-1992  12:30:41 (TH @5, to ALL #3/865, 6/13/92)
  685. * 173 bytes Sat  06-20-1992  17:30:10 (TH @5, changed routines)
  686. * 177 bytes Sun  06-21-1992  16:37:07 (TH @5, bypass empty lines)
  687.  
  688.  
  689. * 
  690. * -------------------------------------------------------------------
  691. * @(5)  Comment or Un-Comment Line or Block,
  692. *       Preserves Indention,
  693. *    >> Insert 'Star Space' at FirstNonWhite of Each Line Commenting,
  694. *       Shifts All Lines Right Two Spaces Commenting,
  695. *       Shift All Lines to Original Position Un-Commenting,
  696. *       Will Un-Comment All Stars as First Character,
  697. *       Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
  698. *       Requires QEdit v2.15,
  699. *    >> Comments Blank Lines
  700. * -------------------------------------------------------------------
  701. * Macro @5 differs from @6 in that @5 inserts a 'star space' at the
  702. * position of the firstnonwhite character of *each* un-commented line
  703. * in the block, thus maintaining indention of each group of indented
  704. * lines.  Although this macro comments blank lines as written, it can
  705. * be modified to not comment blank lines as shown in the macro. 
  706.  
  707. * See Example D above.
  708.  
  709. @5  macrobegin
  710.     setsoundoff setinsmode
  711.         gotoblockend jtrue OK markline
  712.         gotoblockend jtrue OK
  713.         pause                       * Select block if not closed
  714.         markline                    * And close it
  715.     OK:
  716.         setscreenoff
  717.         addline                     * Add line for single line blocks
  718.         markline                    * Extend block to include blank line
  719.         gotoblockbeg
  720.     * ------------------- Test If Block Commented -------------------*
  721.         firstnonwhite cursorright   * Pos 1 spc rt of first char in line
  722.         find "*" return             * Test if line is commented
  723.         "LB" return                 *(assumes all block commented or not)
  724.         jfalse COMMENT              * If no star as first char, comment
  725.     * ----------------------- Un-Comment Block ----------------------*
  726.     UNCOMMENT:                      *ELSE we must un-comment
  727.         firstnonwhite
  728.         delch delch                 * Delete star space
  729.         cursordown                  * Move down 1 line to test if at eob
  730.         iscursorinblock             * Test if past eob
  731.         jtrue UNCOMMENT             * If so, cont until out of block
  732.         jump END                    *ELSE end macro
  733.     * ------------------------ Comment Block ------------------------*
  734.     COMMENT:
  735.         shiftright                  * Shift block right one space
  736.         IS_IN_BLOCK:
  737.             firstnonwhite
  738.             cursorleft
  739.     * --------------------- Comment Blank Lines ---------------------*
  740. *       BLANK:
  741. *           '*'                     * Insert star
  742. *           cursordown              * Move down 1 line to test if at eob
  743. *           iscursorinblock         * Test if past eob
  744. *           jfalse END
  745. *           isemptyline
  746. *       jfalse IS_IN_BLOCK          * Move on if not blank
  747. *           cursorup
  748. *           firstnonwhite
  749. *           cursordown              * Pos cursor underneath top char
  750. *       jump BLANK
  751.     * ---------------------- Bypass Blank Line ----------------------*
  752.             '*'                     * Insert star
  753.         BLANK:
  754.             cursordown              * Move down 1 line to test if at eob
  755.             isemptyline
  756.         jtrue BLANK                 * Bypass blank lines
  757.             iscursorinblock         * Test if past eob
  758.         jtrue IS_IN_BLOCK           * If so, cont until out of block
  759.     * ---------------------------------------------------------------*
  760.     END:
  761.         gotoblockend unmarkblock
  762.         begline delline             * Delete extra blank line
  763. *
  764. * 64 bytes Mon  06-22-1992  15:54:36 (TH @5, bypass blank lines)
  765. * 70 bytes Mon  06-22-1992  15:47:09 (TH @5, comment blank lines)
  766.  
  767.  
  768. * QConfig Version To Fit
  769. * -----------------------
  770. * Changing "Label" to "L", the following QMAC compiled version will fit
  771. * on one line of QConfig.dat (502 chars):
  772.  
  773. * @5 macrobegin setsoundoff setinsmode gotoblockend jtrue L1 markline
  774. *    gotoblockend jtrue L1 pause markline L1: setscreenoff addline
  775. *    markline gotoblockbeg firstnonwhite cursorright find "*" return
  776. *    "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown
  777. *    iscursorinblock jtrue L3 jump L4 L2: setscreenon shiftright L6:
  778. *    firstnonwhite cursorleft L7: "*" cursordown iscursorinblock jfalse
  779. *    L5 isemptyline jfalse L6 cursorup firstnonwhite cursordown jump L7
  780. *    L4 L5: gotoblockend unmarkblock delline begline
  781. * 70 bytes Mon  06-22-1992  15:47:09 (TH @5, comment blank lines)
  782.  
  783. * 
  784. * -------------------------------------------------------------------
  785. * @(6)  Comment or Un-Comment Line or Block,
  786. *       Preserves Indention,
  787. *    >> Insert 'Star Space' at FirstNonWhite Commenting,
  788. *       Shifts All Lines Right Two Spaces Commenting,
  789. *       Shift All Lines to Original Position Un-Commenting,
  790. *       Will Un-Comment All Stars as First Character,
  791. *       Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
  792. *       Requires QEdit v2.15
  793. * -------------------------------------------------------------------
  794. * This macro is useful for preserving indention levels and improving
  795. * readability of commented text, as suggested by Angus Scott-Fleming in
  796. * SemWare Conference 3 Message #865, 06-16-92.
  797.  
  798. * Example (w/o col 1 stars)
  799. * --------------------------
  800.  
  801. *    DO WHILE .T.
  802. *      IF condition THEN
  803. *        DO CASE
  804. *          CASE item = 1
  805. *            * do some thing
  806. *          CASE item = 2                 << Mark these two lines
  807. *            * do some thing else        <<
  808. *          OTHERWISE
  809. *            * punt
  810. *        ENDCASE
  811. *      ELSE
  812. *        * frown
  813. *      ENDIF
  814. *    ENDDO
  815.  
  816.  
  817. * Commenting out CASE item = 2 looks like this:
  818.  
  819. *    DO WHILE .T.
  820. *      IF condition THEN
  821. *        DO CASE
  822. *          CASE item = 1
  823. *            * do some thing
  824. *          * CASE item = 2               << Note: indention Preserveed
  825. *          *   * do some thing else      <<
  826. *          OTHERWISE
  827. *            * punt
  828. *        ENDCASE
  829. *      ELSE
  830. *        * frown
  831. *      ENDIF
  832. *    ENDDO
  833.  
  834. * Also see Example D above.
  835.  
  836.  
  837. @6  macrobegin
  838.     setsoundoff
  839.         gotoblockend jtrue OK markline
  840.         gotoblockend jtrue OK
  841.         pause                       * Select block if not closed
  842.         markline                    * And close it
  843.     OK:
  844.         setscreenoff
  845.         addline                     * Add line for single line blocks
  846.         markline                    * Extend block to include blank line
  847.         gotoblockbeg
  848.     * ------------------- Test If Block Commented -------------------*
  849.         firstnonwhite cursorright   * Pos 1 spc rt of first char in line
  850.         find "*" return             * Test if line is commented
  851.         "LB" return                 *(assumes all block commented or not)
  852.         jfalse COMMENT              * If no star as first char, comment
  853.     * ----------------------- Un-Comment Block ----------------------*
  854.     UNCOMMENT:                      *ELSE we must un-comment
  855.         firstnonwhite
  856.         delch delch                 * Delete star space
  857.         cursordown                  * Move down 1 line to test if at eob
  858.         iscursorinblock             * Test if past eob
  859.         jtrue  UNCOMMENT            * If so, cont until out of block
  860.         jump END                    *ELSE end macro
  861.     * ------------------------ Comment Block ------------------------*
  862.     COMMENT:
  863.         shiftright shiftright       * Make room for the stars
  864.         cursorleft                  * Re-position to insert stars
  865.         gotoblockend
  866.         markcolumn
  867.         prevposition
  868.         markcolumn
  869.         fillblock                   * Fill single column block
  870.             #32  Return             * with space #32 (Change #32 to any
  871.                                     * Ascii char to comment blank lines)
  872.         findreplace                 * Replace
  873.             #32  return             * space
  874.             "*"  return             * with "*"
  875.             "LN" return             * Local, No Prompt Replace
  876.     END:
  877.         gotoblockend unmarkblock
  878.         delline begline             * Delete extra blank line
  879. *
  880. * 105 bytes Tue  06-16-1992  12:39:14 (TH @6, to AS-F #3/868-869 as @4)
  881. * 71 bytes Tue  06-16-1992  17:25:36 (TH @6, shortened w/dummy blank line)
  882. * 72 bytes Sun  06-21-1992  11:54:30 (TH @6, un-comment stars any first char)
  883.  
  884.  
  885. * QConfig Version To Fit
  886. * -----------------------
  887. * Changing "Label" to "L", the following QMAC compiled version will fit
  888. * on one line of QConfig.dat:
  889.  
  890. * @6 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend
  891. *    jtrue L1 pause markline L1: setscreenoff addline markline
  892. *    gotoblockbeg firstnonwhite cursorright find "*" return "lb" return
  893. *    jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock
  894. *    jtrue L3 jump L4 L2: shiftright shiftright cursorleft gotoblockend
  895. *    markcolumn prevposition markcolumn fillblock #32 return
  896. *    findreplace #32 return "*" return "ln" return L4: gotoblockend
  897. *    unmarkblock delline begline
  898. * 72 bytes Sun  06-21-1992  11:54:30
  899.  
  900. * Single line (475 chars)
  901. * ------------------------
  902. * @6 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend jtrue L1 pause markline L1: setscreenoff addline markline gotoblockbeg firstnonwhite cursorright find "*" return "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock jtrue L3 jump L4 L2: shiftright shiftright cursorleft gotoblockend markcolumn prevposition markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock delline begline
  903. *
  904. * 72 bytes Sun  06-21-1992  11:54:30
  905.